home *** CD-ROM | disk | FTP | other *** search
/ SGI Desktop Special Edition 1.1 / SGI Desktop Special Edition 1.1.iso / dist / mmail.idb / usr / lib / Zmail / bin / mailp.z / mailp
Encoding:
Text File  |  1995-11-13  |  2.5 KB  |  122 lines

  1. #! /bin/sh
  2. #
  3. #  @(#)mailp 1.3 92/02/17
  4. #
  5. #  mailp, newsp, filep, digestp, filofaxp, timemanp and timesysp
  6. #  shell script de lancement de mp
  7. #  (mail/news/file/digest/filofax/time-manager/time-system pretty printer)
  8. #
  9. #  Original:   Bruno Pillard      - October 1988.
  10. #  Modified:   Rich Burridge      - June 1989.
  11. #  Revisited:  Larry W. Virden    - August, September 1990.
  12. #  Revisited:  Bruno Pillard      - September 1990.
  13. #  Revisited:  David W. Sanderson - August 1991.
  14.  
  15. BIN=BINDIR
  16.  
  17. #  NOTE: Banner printing is disabled below, by the inclusion of the -h
  18. #        switch to the lpr command. Most of the information that typically
  19. #        appears on the banner sheet, is output in the mp banners. If you
  20. #        wish to enable banner printing, then you should remove the -h switch.
  21.  
  22. PROG=mp
  23. case $BIN in
  24. /*)    PROG=$BIN/mp;;
  25. esac
  26. FLAGS=
  27. STDIN=
  28. LPARGS=
  29.  
  30. case $0 in
  31. *mailp)        ;;
  32. *newsp)     FLAGS=-a  ;;
  33. *digestp)   FLAGS=-d  ;;
  34. *filep)        FLAGS=-o; STDIN=-sstdin ;;
  35. *filofaxp)  FLAGS=-ff ;;
  36. *franklinp) FLAGS=-fp ;;
  37. *timemanp)  FLAGS=-tm ;;
  38. *timesysp)  FLAGS=-ts ;;
  39. *)             echo Unknown pretty printer: $0
  40.         exit ;;
  41. esac
  42.  
  43. # avoid using test - slow in v7 /bin/sh
  44. # while    [ $# -gt 0 ]
  45. for DUMMY in ${1+"$@"}
  46. do
  47.     case $1 in
  48.     # flags to pass through to mp
  49.     -F | -l | -A4)
  50.         FLAGS="$FLAGS $1"
  51.         shift
  52.         ;;
  53.     -s)    FLAGS="$FLAGS -s\"$2\""
  54.         STDIN=
  55.         shift;shift
  56.         ;;
  57.     -s*)    FLAGS="$FLAGS \"$1\""
  58.         STDIN=
  59.         shift
  60.         ;;
  61.     -W)    FLAGS="$FLAGS -W\"$2\""
  62.         shift;shift
  63.         ;;
  64.     -W*)    FLAGS="$FLAGS \"$1\""
  65.         shift
  66.         ;;
  67.     -p)    FLAGS="$FLAGS -p\"$2\""
  68.         shift;shift
  69.         ;;
  70.     -p*)    FLAGS="$FLAGS \"$1\""
  71.         shift
  72.         ;;
  73.  
  74.     # allow both -d and -P to specify the printer name
  75.     -d|-P)    LPDEST="$2"
  76.         PRINTER="$LPDEST"
  77.         shift;shift
  78.         ;;
  79.     -d*|-P*)LPDEST=`echo "$1"|sed 's/^-.//'`
  80.         PRINTER="$LPDEST"
  81.         shift
  82.         ;;
  83.     -h)    LPARGS="$LPARGS -h"
  84.         shift
  85.         ;;
  86.  
  87.     # explicit end of arguments
  88.     --)    shift; break
  89.         ;;
  90.     -*)    LPARGS="$LPARGS \"$1\""
  91.         shift
  92.         ;;
  93.     # stop processing arguments with the first nondash argument
  94.     *)    break
  95.         ;;
  96.     esac
  97. done
  98.  
  99. # If LPDEST or PRINTER is already set in the environment, and no -d or -P
  100. # argument was given, then the appropriate variable will still affect the
  101. # appropriate printing command.
  102. if    [ -d /usr/spool/lp ]
  103. then    PRINT_CMD="lp  ${LPDEST+-d${LPDEST}}   -t"
  104. else    PRINT_CMD="lpr ${PRINTER+-P${PRINTER}} -J"
  105. fi
  106.  
  107. # for v in '*' '#' PROG STDIN FLAGS PRINT_CMD LPARGS
  108. # do    eval echo "\"$v\"" = \"\'\$$v\'\"
  109. # done
  110. # exit 0
  111.  
  112. case $# in
  113. 0)    eval $PROG $STDIN $FLAGS '|' ${PRINT_CMD}stdin $LPARGS
  114.     ;;
  115. *)    for FILE
  116.     do    eval $PROG $FLAGS $FILE | $PRINT_CMD$FILE $LPARGS
  117.     done
  118.     ;;
  119. esac
  120.  
  121. exit 0
  122.